package com.dmzc.stage2.chapter17;

public interface ReadWriteLock {
    /**
     * 创建reader锁
     * @return
     */
    Lock readLock();

    /**
     * 创建write
     * @return
     */
    Lock writeLock();

    /**
     * 获取当前有多少线程正在执行写操作
     * @return
     */
    int getWritingWriters();

    /**
     * 获取当前有多少线程正在等待获取写入锁
     * @return
     */
    int getWaitingWriters();

    /**
     * 获取当前有多少线程正在等待获取reader锁
     * @return
     */
    int getReadingReaders();

    static ReadWriteLock readWriteLock(){
        return  new ReadWriteLockImpl();
    }
    static ReadWriteLock readWriteLock(boolean preferWriter){
        return  new ReadWriteLockImpl(preferWriter);
    }
}
